*clear all
clear matrix
set more off
set linesize 255
pause on
version 15

** This will be called from the top level of the entire replication
global CODE_DIR = "01Code/trading"

global BASELINE_DATA_IN = "00RawData/baseline"
global BASELINE_DATA_OUT = "02DataPipeline/baseline"
global EMISSIONS_DATA_OUT = "02DataPipeline/emissions"
global TRADING_DATA_IN = "00RawData/trading"
global TRADING_DATA_OUT = "02DataPipeline/trading/intermediate"
global TRADING_DATA_CLEAN = "02DataPipeline/trading/cleaned"

global TRADING_TABS="03Output/tables"
global TRADING_FIGS="03Output/figures"

** We use a conversion rate of USD 1 to INR 70, as of 2 Jan 2019, 
** Source: The Fed (https://www.federalreserve.gov/releases/h10/20190107/)
global USD2INR=70


********************************************************************************

** Create intermediate data sets
do "$CODE_DIR/construct_datasets/clean_inventory_data.do"
do "$CODE_DIR/construct_datasets/clean_trading_data.do"
do "$CODE_DIR/construct_datasets/define_periods.do"
do "$CODE_DIR/construct_datasets/check_consistency.do"

** Construct cleaned data sets for analysis
do "$CODE_DIR/construct_datasets/construct_panel_plant-period-date-bid.do"
do "$CODE_DIR/construct_datasets/construct_panel_plant-period-date.do"
do "$CODE_DIR/construct_datasets/construct_panel_plant-period.do"

************** Create scheme **************
grstyle init
grstyle yesno draw_major_hgrid no
grstyle yesno draw_major_vgrid yes
grstyle linepattern major_grid solid

** Plot descriptive figures
* Figure 2
do "$CODE_DIR/plot_time_series.do"
* Figure 3
do "$CODE_DIR/plot_histogram_permit_consumption.do" 3
* Figure 4
do "$CODE_DIR/plot_histogram_permit_consumption.do" 4
* Figure F3
do "$CODE_DIR/plot_histogram_permit_consumption.do" F3
* Figure B2
do "$CODE_DIR/plot_histogram_number_bids.do"

** Estimate elasticity of marginal cost with respect to emissions
* Table 4
do "$CODE_DIR/make_elasticity_table_hetero.do"
* Figure F1
do "$CODE_DIR/make_elasticity_coefplot.do"

* Table 2
do "$CODE_DIR/compute_summary_statistics.do"

